package com.wbcs.config.template.tags;

import com.wbcs.system.ReportRequest;
import com.wbcs.system.assistant.WbcsAssistant;
import com.wbcs.system.component.AbsComponentType;
import com.wbcs.system.component.application.report.abstractreport.AbsReportType;
import com.wbcs.util.Consts_Private;
import com.wbcs.util.Tools;

public class SOutputTag extends AbsTagInTemplate
{
    public SOutputTag(AbsTagInTemplate parentTag)
    {
        super(parentTag);
    }

    @Override
	public String getDisplayValue(ReportRequest rrequest,AbsComponentType ownerComponentObj)
    {
        String value=this.mTagAttributes.get("value");
        if(value==null) return "";
        if(Tools.isDefineKey("request",value)||Tools.isDefineKey("session",value)||Tools.isDefineKey("url",value))
        {//如果是定义从request/session中取动态值显示
            if(Tools.isDefineKey("url",value))
            {
                String urlname=Tools.getRealKeyByDefine("url",value);
                if(ownerComponentObj instanceof AbsReportType)
                {
                    (((AbsReportType)ownerComponentObj).getReportBean()).addParamNameFromURL(urlname);
                }
                rrequest.addParamToUrl(urlname,rrequest.getStringAttribute(urlname,""),false);
            }
            return WbcsAssistant.getInstance().getRequestSessionValue(rrequest,value,"");
        }
        return value;
    }

    @Override
	public String getTagname()
    {
        return Consts_Private.TAGNAME_OUTPUT;
    }
}

